//
//  RootView.m
//  UI6_限时代码
//
//  Created by dllo on 15/11/16.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootView.h"
#import "SubScrollView.h"

@implementation RootView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews
{
    self.backgroundColor = [UIColor whiteColor];

    UIScrollView *scrollV = [[UIScrollView alloc] initWithFrame:self.frame];
    scrollV.contentSize = CGSizeMake(self.frame.size.width * 21, 0);
    scrollV.bounces = YES;
    scrollV.showsHorizontalScrollIndicator = YES;
    scrollV.pagingEnabled = YES;
    scrollV.contentOffset = CGPointMake(self.frame.size.width, 0);
    [self addSubview:scrollV];
    [scrollV release];

    SubScrollView *subScrollV = [[SubScrollView alloc] initWithFrame:self.frame];
    
    for (NSInteger i = 0; i < 21; i++) {

        if (0 == i) {
            subScrollV.imageV.image = [UIImage imageNamed:@"image19.jpg"];
        } else if (20 == i) {
            subScrollV.imageV.image = [UIImage imageNamed:@"image1.jpg"];
        
        } else {
            NSString *fileName = [NSString stringWithFormat:@"image%ld.jpg", i];
            subScrollV.imageV.image = [UIImage imageNamed:fileName];
        }
//        subScrollV.scrollV.frame = CGRectMake(self.frame.size.width * i, 0, self.frame.size.width, self.frame.size.height);
//        [subScrollV.scrollV addSubview:subScrollV.imageV];
        [scrollV addSubview:subScrollV];
        [subScrollV release];
    }




}

@end
